<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 */
namespace app\bbs\api;

use app\common\api\BaseApi;
use app\bbs\model\ForumSilent;

class ForumSilentApi extends BaseApi{
    const ADD  = "bbs/ForumSilentApi/add";
    const SAVE = "bbs/ForumSilentApi/save";
    const GET_INFO  = "bbs/ForumSilentApi/getInfo";
    const IS_SILENT = "bbs/ForumSilentApi/isSilent";

    protected function _init(){
        $this -> model = new ForumSilent();
    }

    public function isSilent($uid){
    	$r = $this->getInfo(' `uid`=\''.$uid.'\' and `end_time`>='.NOW_TIME,'start_time desc');
    	if(!$r['status']) return $this -> apiReturnErr($r['info']);
			if(empty($r['info'])) return  $this -> apiReturnSuc(false);
			if($r['info']['end_time'] <= $r['info']['start_time']){
			    return $this -> apiReturnSuc('您已被禁言：结束时间：世界末日！');
			}else{
			    return $this->apiReturnSuc('您已被禁言：结束时间：'.getDateDiff($r['info']['end_time']));
			}
    }
}